﻿<!--#include file="const.inc"-->
<%
'====================================================================
' 感谢使用晴天3G智能建站系统..
' 作者:梁永强.QQ:766750857
' 官方网址:wap.qt3g.com
' 声明:软件版权归作者所有,没有经过作者本人同意不得非法破解和传播本程序
'====================================================================
%>
<%
if sid="Null" then
Response.Redirect "/login.asp?sid="&sidd&"&url=/game/wulon/index.asp"
else
IF  Request.QueryString("Action")="login" Then
	call loginn
else
	call index
end if
end if
end Function
Function index
        dim pid,mon,body,id,act,mynid
	id=Request.QueryString("id")
	if id="" then id=1
	if not isnumeric(id) then id=1
	id=clng(id)
	pid=Request.QueryString("pid")
	if pid="" then pid=1
	if not isnumeric(pid) then pid=1
	pid=clng(pid)
	act=Request.QueryString("act")
	if act="" then act=0
	if not isnumeric(act) then act=0
	act=clng(act)
        if act<>1 and act<>2 and act<>0 then act=0
        mon=sangong.namejian("money",pid)
        mynid=qingtian.nid
select case v
case "0"
we0="<br/>"
hr="----------------<br/>"
body="下注<a href='gamed.asp?pid="&pid&"&amp;id="&id&"&amp;mid="&int(mon/5)&"&amp;Action=login&amp;sid=" & sidd & "'>"&int(mon/5)&"</a>.<a href='gamed.asp?pid="&pid&"&amp;id="&id&"&amp;mid="&int(mon/2)&"&amp;Action=login&amp;sid="&sidd&"'>"&int(mon/2)&"</a>.<a href='gamed.asp?pid="&pid&"&amp;id="&id&"&amp;mid="&mon&"&amp;Action=login&amp;sid="&sidd&"'>"&mon&"</a><br/><input name='mid' format='*N' size='15' maxlength='10'/><br/>最高不能超过"&mon&"<br/><anchor>下注<go href='gamed.asp?pid="&pid&"&amp;id="&id&"&amp;Action=login&amp;sid="&sidd&"' method='post'><postfield name=""mid"" value=""$(mid:n)"" /></go></anchor><br/>"
%>
<card id="main" title="疯狂牛牛"><p align="<%=qingtian.px%>">
<%
case "1"
zi="<span style=""color:#FF5500"">"
zi0="</span>"
we="<div class=""footer"">"
sou="<div class=""block4"">"
dao="<div class=""navi"">"
we0="</div>"
we1="</div>"
ziz="<div style=""background-color:#FF5226;font-size:16px;color:#E1E100"">"
body="<div class=""footer"">下注<a href='gamed.asp?pid="&pid&"&amp;id="&id&"&amp;mid="&int(mon/5)&"&amp;Action=login&amp;sid=" & sidd & "'>"&int(mon/5)&"</a>.<a href='gamed.asp?pid="&pid&"&amp;id="&id&"&amp;mid="&int(mon/2)&"&amp;Action=login&amp;sid=" & sidd & "'>"&int(mon/2)&"</a>.<a href='gamed.asp?pid="&pid&"&amp;id="&id&"&amp;mid="&mon&"&amp;Action=login&amp;sid=" & sidd & "'>"&mon&"</a></div><form action='gamed.asp?pid="&pid&"&amp;id="&id&"&amp;Action=login&amp;sid="&sidd&"' method='post'><input emptyok='true' format='*N' type='text' name='mid' value='' size='15'/><br/><div class=""block4"">最高不能超过"&mon&"</div><input type='submit' value='下注'/></form><br/>"
%>
<title>疯狂牛牛</title>
</head>
<body>
<!--#include virtual="/css.inc"-->
<%
End Select
if sangong.namere("aid",mynid)<>0 and sangong.namere("aid",mynid)<>id then
qingtian.err("你还在游戏中<a href='gamed.asp?Action=login&amp;pid="&pid&"&amp;id="&sangong.namere("aid",mynid)&"&amp;sid=" & sidd & "'>返回继续游戏</a>")
end if 
if sangong.mobe(id)=4 and sangong.namere("ton",mynid)=0 then
qingtian.err("该卓游戏已满4人<a href='fangd.asp?action=1&amp;id="&pid&"&amp;sid=" & sidd & "'>返回上级</a>")
end if
sangong.pd(sangong.namefa("pid",id))
%>
<%=ziz%>★★我要下注★★<%=we0%><%=dao%>
【等待玩家】<a href='gamed.asp?pid=<%=pid%>&amp;id=<%=id%>&amp;sid=<%=sidd%>'>刷新</a><%=we0%><%=hr%>
<% if act=0 then%>
<%=we%>庄家<%=sangong.moname3(id,pid)%><br/>闲家<%=sangong.moname2(id,pid)%><%=we0%> 
<%elseif act=1 then
if conn.execute("select money from [qingtian_user] where sid='"&qingtian.Formatsid(sid)&"'")("money")>3*mon then
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select top 1 * FROM qingtian_reton where aid="&id&" and ton=2 order by id asc"
	Rs.Open Sql,cn,1,1
		if rs.bof and rs.eof  then  
	Set Rss = Server.CreateObject("Adodb.Recordset")
	Sqls = "select top 1 * FROM qingtian_reton where nid="&mynid&" order by nid asc"
	Rss.Open Sqls,cn,1,3
		if not (rss.bof and rss.eof)  then 
                rss("ton")=2
                rss("aid")=id
                rss("bid")=pid
	rss.update
        end if
	Rss.close
       set rss=nothing
Response.Redirect "gamed.asp?pid="&pid&"&id="&id&"&Action=login&sid="&sidd&""
       else
%>
<%=we%>坐庄失败,该卓游戏已经有庄家了<a href='gamed.asp?act=2&amp;pid=<%=pid%>&amp;id=<%=id%>&amp;sid=<%=sidd%>'>进入闲家下注</a><%=we0%> 
<%
                end if
	Rs.close
       set rs=nothing 
else
%>
<%=we%>坐庄失败,坐庄最小需要拥有<%=qingtian.bi%><%=3*mon%><a href='gamed.asp?act=2&amp;pid=<%=pid%>&amp;id=<%=id%>&amp;sid=<%=sidd%>'>进入闲家下注</a><%=we0%> 
<%
end if
elseif act=2 then
if sangong.namere("ton",mynid)=2 then 
%>
<%=we%>坐闲失败,你已经是庄家了<a href='gamed.asp?action=login&amp;pid=<%=pid%>&amp;id=<%=id%>&amp;sid=<%=sidd%>'>返回继续游戏</a><%=we0%> 
<%
else
%>
<%=body%>
<%end if%>
<%end if%>
<%=we%>账户:<%=zi%><%=conn.execute("select money from [qingtian_user] where sid='"&qingtian.Formatsid(sid)&"'")("money")%><%=qingtian.bi%><%=zi0%><%=we0%><%=sou%>
<a href="fangd.asp?action=1&amp;id=<%=pid%>&amp;sid=<%=sidd%>">返回上级</a>.<a href="/game/wulon/index.asp?sid=<%=sidd%>">疯狂牛牛</a><%=we0%>

<%
end Function



Function loginn
dim id,a,b,nid,rs,sql,i,d,rss,sqls,mynid,monn
	id=Request.QueryString("id")
	if id="" then id=1
	if not isnumeric(id) then id=1
	id=clng(id)
	pid=Request.QueryString("pid")
	if pid="" then pid=1
	if not isnumeric(pid) then pid=1
	pid=clng(pid)
        mynid=qingtian.nid
select case v
case "0"
we0="<br/>"
hr="----------------<br/>"
%>
<card id="main" title="疯狂牛牛"><p align="<%=qingtian.px%>">
<%
case "1"
zi="<span style=""color:#FF5500"">"
zi0="</span>"
we="<div class=""footer"">"
sou="<div class=""block4"">"
dao="<div class=""navi"">"
we0="</div>"
we1="</div>"
ziz="<div style=""background-color:#FF5226;font-size:16px;color:#E1E100"">"
%>
<title>疯狂牛牛</title>
</head>
<body>
<!--#include virtual="/css.inc"-->
<%
End Select
if Request.QueryString("act")=2 then
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select top 1 * FROM qingtian_reton where nid="&mynid&" order by id asc"
	Rs.Open Sql,cn,1,3
		if not (rs.bof and rs.eof)  then 
                rs("ton")=0
                rs("time")=now()
                rs("aid")=0
                rs("bid")=0
	rs.update
        end if
	Rs.close
       set rs=nothing
Response.Redirect "fangd.asp?sid="&sidd&"&id="&sangong.namefa("pid",id)
end if
qingtian.info
if sangong.namere("aid",mynid)<>0 and sangong.namere("aid",mynid)<>id then
qingtian.err("你还在游戏中<a href='gamed.asp?Action=login&amp;pid="&pid&"&amp;id="&sangong.namere("aid",mynid)&"&amp;sid=" & sidd & "'>返回继续游戏</a>")
end if 
if sangong.mobe(id)=4 and sangong.namere("ton",mynid)=0 then
qingtian.err("该卓游戏已满4人<a href='fangd.asp?id="&pid&"&amp;sid=" & sidd & "'>返回上级</a>")
end if
sangong.pd(sangong.namefa("pid",id))
%>
<%=ziz%>☆疯狂牛牛☆<%=we0%>
<%=dao%>玩家(<%=zi%><%=sangong.moname(id)%><%=zi0%>)<%=we0%><%=hr%><%=we%>
<%
if sangong.namefa("ton",id)=0 then
          if sangong.namere("ton",mynid)=0 then
money=sangong.namejian("money",pid)
if sangong.namere("ton",mynid)<>2 then
	midd=Request("mid")
	if midd="" then Response.Redirect "gamed.asp?act=2&pid="&pid&"&id="&id&"&sid="&sidd
	if not isnumeric(midd) then midd=10
	midd=clng(midd)
        if midd>money then qingtian.err("下注金额不能超过"&money&"")
end if
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select top 1 * FROM qingtian_reton where nid="&mynid&" order by id asc"
	Rs.Open Sql,cn,1,3
		if not (rs.bof and rs.eof)  then 
                rs("ton")=1
                rs("time")=now()
                rs("aid")=id
                rs("bid")=pid
                rs("money")=midd
	rs.update
        end if
	Rs.close
	Sql = "select top 1 * FROM qingtian_fangd where id="&id&" order by id asc"
	Rs.Open Sql,cn,1,3
		if not (rs.bof and rs.eof)  then 
                rs("time")=now()
                 rs("c")=session("username")&"进入游戏"
	rs.update 
        end if
	Rs.close
       set rs=nothing
          Response.Write("请等待10秒[<a href='gamed.asp?Action=login&amp;id="&id&"&amp;pid="&pid&"&amp;sid="&sidd&"'>刷新</a>|<a href='gamed.asp?act=2&amp;Action=login&amp;id="&id&"&amp;pid="&pid&"&amp;sid="&sidd&"'>退出</a>]<br/>")
          else
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select top 1 * FROM qingtian_reton where aid="&id&" and ton=2 order by id asc"
	Rs.Open Sql,cn,1,1
		if rs.bof and rs.eof  then  
                rssurl=true
                end if
	Rs.close
       set rs=nothing 
          if sangong.mobe(id)=1 or rssurl=true then 
          Response.Write("暂无闲家或庄家进入游戏!<br/>请等待[<a href='gamed.asp?Action=login&amp;id="&id&"&amp;pid="&pid&"&amp;sid="&sidd&"'>刷新</a>|<a href='gamed.asp?act=2&amp;Action=login&amp;id="&id&"&amp;pid="&pid&"&amp;sid="&sidd&"'>退出</a>]<br/>")
          else
          if sangong.mobe(id)=4 or DATEDIFF("s", sangong.namefa("time",id), now()) > 10 then
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select top 1 * FROM qingtian_fangd where id="&id&" order by id asc"
	Rs.Open Sql,cn,1,3
		if not (rs.bof and rs.eof)  then 
                rs("ton")=1 
                rs("time")=now() 
	rs.update 
        end if
	Rs.close
       set rs=nothing
       sangong.game(id)

	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select top 1 * FROM qingtian_reton where aid="&id&" and ton=2 order by id asc"
	Rs.Open Sql,cn,1,1
		if not (rs.bof and rs.eof)  then  
                a=rs("a")
                b=rs("b")
                nid=rs("nid")
                end if
	Rs.close
       set rs=nothing 

	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select * FROM qingtian_reton where aid="&id&" and ton<>2 order by nid asc"
	Rs.Open Sql,cn,1,3
		if not (rs.bof and rs.eof)  then
                lui=sangong.namejian("pid",pid)
 		For i=1 to rs.RecordCount
                mon=rs("money")
                if rs("a") > a then
                if rs("a")=100 then
                mon=mon*5
                elseif rs("a")>6 and rs("a")<>10 then
                mon=mon*2
                elseif rs("a")=10 then
                mon=mon*3
                end if
                rs("shen")=rs("shen")+1
                rs("d")=int(mon)*(1-lui/100)
                qingtian.pay int(mon)*(1-lui/100),rs("nid")
                d=int(mon)+d 
                rs("m")=rs("m")+int(mon)*(1-lui/100)
                elseif rs("a") < a then
                if a=100 then
                mon=mon*5
                elseif a>6 and a<>10 then
                mon=mon*2
                elseif a=10 then
                mon=mon*3
                end if
                rs("shu")=rs("shu")+1
                rs("d")=-int(mon)
                qingtian.pay -int(mon),rs("nid")
                d=d-int(mon)
                rs("m")=rs("m")-int(mon) 
                elseif rs("a")=a then
                if a=100 then
                mon=mon*5
                elseif a>6 and a<>10 then
                mon=mon*2
                elseif a=10 then
                mon=mon*3
                end if
                if rs("b") > b then
                rs("shen")=rs("shen")+1
                rs("d")=int(mon)*(1-lui/100)
                qingtian.pay int(mon)*(1-lui/100),rs("nid") 
                d=int(mon)+d 
                rs("m")=rs("m")+int(mon)*(1-lui/100)
                else
                rs("shu")=rs("shu")+1
                rs("d")=-int(mon)
                qingtian.pay -int(mon),rs("nid")
                d=d-int(mon)
                rs("m")=rs("m")-int(mon)
                end if
                end if 
	        rs.update                            
		Rs.MoveNext
		next
                end if
       Rs.close
       set rs=nothing 
             
        d=-d
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select top 1 * FROM qingtian_reton where nid="&nid&" order by id asc"
	Rs.Open Sql,cn,1,3
		if not (rs.bof and rs.eof)  then 
                if d>0 then
                d=d*(1-lui/100)
                rs("m")=rs("m")+d
                rs("shen")=rs("shen")+1
                else
                rs("m")=rs("m")+d
                rs("shu")=rs("shu")+1
                end if
                rs("d")=d
	rs.update
        end if
	Rs.close
       set rs=nothing 
                if d>0 then
                qingtian.pay d,nid
strs=""&nid&"tt恭喜,你在游戏“[url=/game/wulon/index.asp?sid=[sid]]牛牛[/url]”中赢了,系统自动为你增加"&int(d)&""&qingtian.bi&"!"
qingtian.addnfo(strs)
                else
                qingtian.pay d,nid
strs=""&nid&"tt很遗憾你在游戏“[url=/game/wulon/index.asp?sid=[sid]]牛牛[/url]”中输了,系统自动扣除你"&-int(d)&""&qingtian.bi&"!"
qingtian.addnfo(strs)
                end if
                
          if sangong.namere("d",mynid)<0 then
          Response.Write("很遗憾你输了,系统自动扣除你"&zi&""&abs(sangong.namere("d",mynid))&""&qingtian.bi&""&zi0&"!<br/>") 
          qingtian.addong("在游戏[url=/game/wulon/index.asp?sid=[sid]]牛牛[/url]中输掉了"&qingtian.bi&"")        
          else
          Response.Write("恭喜,你赢了系统为你增加"&zi&""&sangong.namere("d",mynid)&""&qingtian.bi&""&zi0&"!<br/>") 
          qingtian.addong("在游戏[url=/game/wulon/index.asp?sid=[sid]]牛牛[/url]中赢得了"&qingtian.bi&"")   
          end if
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select * FROM qingtian_reton where aid="&id&" order by id asc"
	Rs.Open Sql,cn,1,1
		if not (rs.bof and rs.eof)  then
 		For i=1 to rs.RecordCount
                if rs("nid")=mynid then
                tt="你的"
                else
                tt=qingtian.name(rs("nid"))
                end if
                if rs("nid")=nid then 
                pp=""&zi&"(庄)"&zi0&""
                else
                pp=""
                end if
                if rs("a")=100 then
                aa="五龙"
                elseif rs("a")=0 then
                aa="无牛"
                elseif rs("a")=10 then
                aa="牛牛"
                else
                aa="牛"&rs("a")
                end if
                Response.Write(""&tt&"的牌"&pp&"："&zi&""&aa&""&zi0&"<br/>"&sangong.pai(rs("c"))&"<br/>")                
		Rs.MoveNext
		next
                end if
       Rs.close
       set rs=nothing 
          Response.Write("是否继续游戏:<br/>1.<a href='gamed.asp?Action=login&amp;id="&id&"&amp;pid="&pid&"&amp;sid="&sidd&"'>继续</a><br/>2.<a href='gamed.asp?Action=login&amp;act=2&amp;id="&id&"&amp;pid="&pid&"&amp;sid="&sidd&"'>退出</a><br/>")
          else
          timee=10-DATEDIFF("s", sangong.namefa("time",id), now())
          Response.Write(""&sangong.namefa("c",id)&"<br/>请等待"&timee&"秒[<a href='gamed.asp?Action=login&amp;id="&id&"&amp;pid="&pid&"&amp;sid="&sidd&"'>刷新</a>|<a href='gamed.asp?act=2&amp;Action=login&amp;id="&id&"&amp;pid="&pid&"&amp;sid="&sidd&"'>退出</a>]<br/>")
          end if
          end if
          end if
else
        if DATEDIFF("s", sangong.namefa("time",id), now()) > 20 then
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select * FROM qingtian_reton where aid="&id&" order by id asc"
	Rs.Open Sql,cn,1,3
		if not (rs.bof and rs.eof)  then 
 		For i=1 to rs.RecordCount
                rs("ton")=0
                rs("aid")=0
                rs("bid")=0
                rs("time")=now()
	        rs.update
		Rs.MoveNext
		next
        end if
	Rs.close
	Sql = "select top 1 * FROM qingtian_fangd where id="&id&" order by id asc"
	Rs.Open Sql,cn,1,3
		if not (rs.bof and rs.eof)  then 
                rs("ton")=0 
	rs.update 
        end if
	Rs.close
       set rs=nothing
        Response.Write("本局游戏已经结出.<br/>是否继续游戏:<br/>1.<a href='gamed.asp?Action=login&amp;id="&id&"&amp;pid="&pid&"&amp;sid="&sidd&"'>继续</a><br/>2.<a href='gamed.asp?Action=login&amp;act=2&amp;id="&id&"&amp;pid="&pid&"&amp;sid="&sidd&"'>退出</a><br/>") 
        else
          if sangong.namere("d",mynid)<0 then
          Response.Write("很遗憾你输了,系统自动扣除你"&zi&""&abs(sangong.namere("d",mynid))&""&qingtian.bi&""&zi0&"!<br/>")          
          else
          Response.Write("恭喜,你赢了系统为你增加"&zi&""&sangong.namere("d",mynid)&""&qingtian.bi&""&zi0&"!<br/>") 
          end if
          t=sangong.namefa("c",id)
          t=split(t,"|")
          for i=0 to UBound(t)
          nnid=left(t(i),instr(t(i),":")-1)
          nnidd=split(nnid,",")
          anid=nnidd(0)
          aaa=nnidd(1)
          aton=nnidd(2)
          nstr=Replace(t(i),nnid&":","")
                if clng(anid)=clng(mynid) then
                ttt="你的"
                else
                ttt=qingtian.name(anid)
                end if
                if aton=2 then 
                ppp=""&zi&"(庄)"&zi0&""
                else
                ppp=""
                end if
                if aaa=100 then
                aaa="五龙"
                elseif aaa=0 then
                aaa="无牛"
                elseif aaa=10 then
                aaa="牛牛"
                else
                aaa="牛"&aaa
                end if
          Response.Write(""&ttt&"的牌"&ppp&"："&zi&aaa&zi0&"<br/>"&sangong.pai(nstr)&"<br/>")
          next
          timee=20-DATEDIFF("s", sangong.namefa("time",id), now())
          Response.Write("请等待"&timee&"秒[<a href='gamed.asp?Action=login&amp;id="&id&"&amp;pid="&pid&"&amp;sid="&sidd&"'>刷新</a>|<a href='gamed.asp?act=2&amp;id="&id&"&amp;Action=login&amp;pid="&pid&"&amp;sid="&sidd&"'>退出</a>]<br/>")
          end if
end if



%>
<%=we1%><%=hr%><%=sou%>账户:<%=zi%><%=conn.execute("select money from [qingtian_user] where sid='"&qingtian.Formatsid(sid)&"'")("money")%><%=zi0%><%=qingtian.bi%><%=we0%><%=ziz%><a href="fangd.asp?action=1&amp;id=<%=pid%>&amp;sid=<%=sidd%>">返回上级</a>.<a href="/game/wulon/index.asp?sid=<%=sidd%>">疯狂牛牛</a><%=we0%>
<%
end function
%>